package com.example.broadcast3;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.widget.Toast;

public class MainActivity extends AppCompatActivity {
    private static final String TAG = "MainActivity";

    private IntentFilter intentFilter;

    private BroadcastReceiver3 broadcastReceiver3;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        intentFilter = new IntentFilter();
        intentFilter.addAction("com.example.lxd.My_Broadcast");
        broadcastReceiver3 = new BroadcastReceiver3();
        registerReceiver(broadcastReceiver3, intentFilter);
    }

    class BroadcastReceiver3 extends BroadcastReceiver {

        @Override
        public void onReceive(Context context, Intent intent) {
            Bundle bundle = getResultExtras(true);
            String first = bundle.getString("first");
            Log.d(TAG, "onReceive: receive broadcast3" + first);
        }
    }
}
